<template>
  <div class="app-container">
    <el-dialog title="日志列表" :visible.sync="dialogFormVisible">
      <el-table
        ref="multipleTable"
        :data="list"
        border
        style="width: 100%"
        v-loading="listLoading">
        <el-table-column align="center"
          prop="beanName"
          label="任务类名">
        </el-table-column>
        <el-table-column align="center"
          prop="params"
          label="参数">
        </el-table-column>
        <el-table-column align="center"
          prop="status"
          label="状态">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.status === 0" type="success">成功</el-tag>
            <el-tag v-if="scope.row.status === 1" type="info">失败</el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center"
          prop="times"
          label="耗时(单位：毫秒)">
        </el-table-column>
        <el-table-column align="center"
          prop="error"
          label="失败信息">
        </el-table-column>
        <el-table-column align="center"
          prop="createTime"
          label="创建时间">
        </el-table-column>
      </el-table>
      <!-- 分页插件 -->
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :page-sizes="[20, 50, 100, 200]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
    </el-dialog>
  </div>
</template>

<script>
  import quartzListApi from '@/api/quartz/list'
  export default {
    data () {
      return {
        list: [],
        listLoading: false,
        pageNo: 1,
        pageSize: 20,
        dialogFormVisible: false,
        total: 0
      }
    },
    created () {},
    methods: {
      init() {
        this.dialogFormVisible = true
        quartzListApi.listLog({
          pageNo: this.pageNo, 
          pageSize: this.pageSize
        }).then(res => {
          this.list = res.data.pages.records
          this.total = res.data.pages.total
          this.listLoading = false
        }).catch(res => {
          this.list = []
          this.total = 0
          this.listLoading = false
        })
      },
      // 每页多少条数据
      handleSizeChange(val) {
        this.pageSize = val
      },
      // 当前第几页
      handleCurrentChange(val) {
        this.pageNo = val
      }
    }
  }
</script>

<style scoped></style>